
<div class="layuimini-main">

    <div class="layui-form layuimini-form" lay-filter="saveBtn">

        <div class="layui-form-item">
            <label class="layui-form-label required">进出时间</label>
            <div class="layui-input-block">
                <input type="text" name="recTime" id="recTime" lay-verify="required"  placeholder="进出时间:  yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">进出类型</label>
            <div class="layui-input-block">
                <input type="radio" name="recType" value="进" title="进" checked>
                <input type="radio" name="recType" value="出" title="出">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label required">住户编号</label>
            <div class="layui-input-block">
                <input type="number" name="recPersonId" min="0" lay-verify="required" lay-reqtext="住户编号不能为空" placeholder="请输入住户编号" value="" class="layui-input">
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label required">出入地点</label>
            <div class="layui-input-block">
                <input type="text" name="recOrderadd"  lay-verify="required" lay-reqtext="出入地点不能为空" placeholder="请输入出入地点" value="" class="layui-input">
                <tip>从何处来，到何处去</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">住户体温</label>
            <div class="layui-input-block">
                <input type="text" name="recTempera" placeholder="请输入进出人体温,精确到小数点后一位 如：36.5" value="36.5" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <input type="text" name="recRemark" placeholder="备注信息" value="" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <!--            <label class="layui-form-label required ">登记类型</label>-->
            <div class="layui-input-block">
                <input type="hidden" name="recPerType"  lay-reqtext="姓名不能为空" placeholder="请输入登记者姓名" value="0" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认添加</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();


        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;
        laydate.render({
            elem:'#recTime',
            type:'datetime',
            format:'yyyy-MM-dd HH:mm:ss',
            value:new Date(),
            min: '2000-01-01 00:00:00',
            }
        );
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var datas = data.field;
            if (datas.recType == '进'){
                datas.recType = 1;
            }else{
                datas.recType = 0;
            }
            var loadIndex = layer.load(2);
            $.ajax({
                url: '/records/addRecord',
                type: 'post',
                data: datas,
                dataType: "json",
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code == '200') {
                        layer.msg(res.msg, {
                            icon: 6,
                            time: 300},function () {
                            parent.window.location.reload();//刷新页面
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex)
                        });
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, error: function () {
                    layer.close(loadIndex);
                    layer.msg('网页出错了,即将跳转异常页', {icon: 2,time:1500});
                    window.location.href = '/User/404'
                }
            });
            return false;
        });

    });
</script>
</html>
